from sqlalchemy import Column, String, Text, DateTime, UUID
from sqlalchemy.sql import func
import uuid
from db.connection import Base


class ConversationHistory(Base):
    __tablename__ = "conversation_histories"

    id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    user_id = Column(String, index=True, nullable=False)
    session_id = Column(String, index=True, nullable=False)
    user_message = Column(Text, nullable=False)
    bot_response = Column(Text)
    image_url = Column(String)
    intent = Column(String)
    created_at = Column(DateTime(timezone=True), server_default=func.now())

    def __repr__(self):
        return f"<ConversationHistory(user_id={self.user_id}, session_id={self.session_id})>"
